<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="generator" content="VuePress 2.0.0-beta.63">
    <style>
      :root {
        --c-bg: #fff;
      }
      html.dark {
        --c-bg: #22272e;
      }
      html, body {
        background-color: var(--c-bg);
      }
    </style>
    <script>
      const userMode = localStorage.getItem('vuepress-color-scheme');
			const systemDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
			if (userMode === 'dark' || (userMode !== 'light' && systemDarkMode)) {
				document.documentElement.classList.toggle('dark', true);
			}
    </script>
    <link rel="apple-touch-icon" href="/preview/dev-edge/static/images/icons/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/preview/dev-edge/static/images/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/preview/dev-edge/static/images/icons/favicon-32x32.png"><link rel="mask-icon" color="#5bbad5" href="/preview/dev-edge/static/images/icons/safari-pinned-tab.svg"><link rel="manifest" href="/preview/dev-edge/manifest.webmanifest"><meta name="theme-color" content="#3eaf7c"><title>HTML基础知识 | 编程宝典</title><meta name="description" content="技术文档系列">
    <link rel="preload" href="/preview/dev-edge/assets/style-f70c0240.css" as="style"><link rel="stylesheet" href="/preview/dev-edge/assets/style-f70c0240.css">
    <link rel="modulepreload" href="/preview/dev-edge/assets/app-5517e208.js"><link rel="modulepreload" href="/preview/dev-edge/assets/index.html-e16c539b.js"><link rel="modulepreload" href="/preview/dev-edge/assets/index.html-27bb8266.js"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-b0802b3f.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-91808b4b.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/companyWebSite.html-9e7a30c8.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-4262c6b6.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-6497e968.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-2b3ce734.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-c1d52a82.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-193e0fce.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-8ef690da.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-6ead1acd.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-2612aedd.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/element.html-433d6fa7.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/others.html-0fd00d80.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-d5a68135.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-f9d64ee4.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/note.html-c888e7ae.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/standard.html-a01ab960.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/chapter01.html-9437ac94.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/3Dweb.html-a089b8c2.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/efficientOffice.html-738b652c.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/jsBase.html-57994080.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/shareDays.html-3bf22bb6.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-f50cfc3a.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-d5c469ee.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/404.html-1f2dab39.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-5eb236d0.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-1a6bf188.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/companyWebSite.html-cf3c257a.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-0825c4b1.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-60fc4bf3.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-ade72257.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-6916a41b.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-7604bfc1.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-b898dcab.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-5dc09f61.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-d7c5567b.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/element.html-67b8ba8a.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/others.html-243c60b2.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-38035162.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-301c45fe.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/note.html-a409283d.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/standard.html-1078c00a.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/chapter01.html-a87c4022.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/3Dweb.html-ce93ff55.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/efficientOffice.html-eb2a5cdf.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/jsBase.html-598d0a7a.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/shareDays.html-44350d8b.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-58ddc7ce.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index.html-a8b21767.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/404.html-2796e91e.js" as="script"><link rel="prefetch" href="/preview/dev-edge/assets/index-e32a7948.js" as="script">
  </head>
  <body>
    <div id="app"><!--[--><div class="theme-container"><!--[--><header class="navbar"><div class="toggle-sidebar-button" title="toggle sidebar" aria-expanded="false" role="button" tabindex="0"><div class="icon" aria-hidden="true"><span></span><span></span><span></span></div></div><span><a href="/preview/dev-edge/" class=""><img class="logo" src="/preview/dev-edge/static/images/icons/android-chrome-192x192.png" alt="编程宝典"><span class="site-name can-hide">编程宝典</span></a></span><div class="navbar-items-wrapper" style=""><!--[--><!--]--><nav class="navbar-items can-hide"><!--[--><div class="navbar-item"><div class="navbar-dropdown-wrapper"><button class="navbar-dropdown-title" type="button" aria-label="前端"><span class="title">前端</span><span class="arrow down"></span></button><button class="navbar-dropdown-title-mobile" type="button" aria-label="前端"><span class="title">前端</span><span class="right arrow"></span></button><ul style="display:none;" class="navbar-dropdown"><!--[--><li class="navbar-dropdown-item"><!--[--><h4 class="navbar-dropdown-subtitle"><span>基础知识</span></h4><ul class="navbar-dropdown-subitem-wrapper"><!--[--><li class="navbar-dropdown-subitem"><a aria-current="page" href="/preview/dev-edge/frontend/html/" class="router-link-active router-link-exact-active router-link-active" aria-label="html"><!--[--><!--]--> html <!--[--><!--]--></a></li><li class="navbar-dropdown-subitem"><a href="/preview/dev-edge/frontend/css/" class="" aria-label="css"><!--[--><!--]--> css <!--[--><!--]--></a></li><li class="navbar-dropdown-subitem"><a href="/preview/dev-edge/frontend/javascript/" class="" aria-label="Javascript"><!--[--><!--]--> Javascript <!--[--><!--]--></a></li><!--]--></ul><!--]--></li><li class="navbar-dropdown-item"><!--[--><h4 class="navbar-dropdown-subtitle"><span>高级进阶</span></h4><ul class="navbar-dropdown-subitem-wrapper"><!--[--><li class="navbar-dropdown-subitem"><a href="/preview/dev-edge/frontend/vue/" class="" aria-label="Vue"><!--[--><!--]--> Vue <!--[--><!--]--></a></li><!--]--></ul><!--]--></li><li class="navbar-dropdown-item"><!--[--><h4 class="navbar-dropdown-subtitle"><span>插件及组件库</span></h4><ul class="navbar-dropdown-subitem-wrapper"><!--[--><li class="navbar-dropdown-subitem"><a href="/preview/dev-edge/frontend/libs/" class="" aria-label="导航"><!--[--><!--]--> 导航 <!--[--><!--]--></a></li><!--]--></ul><!--]--></li><li class="navbar-dropdown-item"><!--[--><h4 class="navbar-dropdown-subtitle"><span>综合</span></h4><ul class="navbar-dropdown-subitem-wrapper"><!--[--><li class="navbar-dropdown-subitem"><a href="/preview/dev-edge/frontend/others/standard" class="" aria-label="前端开发规范"><!--[--><!--]--> 前端开发规范 <!--[--><!--]--></a></li><li class="navbar-dropdown-subitem"><a href="/preview/dev-edge/frontend/others/note" class="" aria-label="前端知识点"><!--[--><!--]--> 前端知识点 <!--[--><!--]--></a></li><!--]--></ul><!--]--></li><!--]--></ul></div></div><div class="navbar-item"><div class="navbar-dropdown-wrapper"><button class="navbar-dropdown-title" type="button" aria-label="后端"><span class="title">后端</span><span class="arrow down"></span></button><button class="navbar-dropdown-title-mobile" type="button" aria-label="后端"><span class="title">后端</span><span class="right arrow"></span></button><ul style="display:none;" class="navbar-dropdown"><!--[--><li class="navbar-dropdown-item"><a href="/preview/dev-edge/backend/java/" class="" aria-label="java"><!--[--><!--]--> java <!--[--><!--]--></a></li><li class="navbar-dropdown-item"><a href="/preview/dev-edge/backend/python/" class="" aria-label="python"><!--[--><!--]--> python <!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-item"><a href="/preview/dev-edge/storage/" class="" aria-label="版本库"><!--[--><!--]--> 版本库 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/preview/dev-edge/manage/" class="" aria-label="管理"><!--[--><!--]--> 管理 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/preview/dev-edge/project/" class="" aria-label="项目"><!--[--><!--]--> 项目 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/preview/dev-edge/system/" class="" aria-label="系统"><!--[--><!--]--> 系统 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/preview/dev-edge/share/" class="" aria-label="分享"><!--[--><!--]--> 分享 <!--[--><!--]--></a></div><div class="navbar-item"><a class="external-link" href="https://gitee.com/chengmaofeng/dev-edge" rel="noopener noreferrer" target="_blank" aria-label="Gitee"><!--[--><!--]--> Gitee <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span><!--[--><!--]--></a></div><!--]--></nav><!--[--><!--]--><button class="toggle-color-mode-button" title="toggle color mode"><svg style="" class="icon" focusable="false" viewBox="0 0 32 32"><path d="M16 12.005a4 4 0 1 1-4 4a4.005 4.005 0 0 1 4-4m0-2a6 6 0 1 0 6 6a6 6 0 0 0-6-6z" fill="currentColor"></path><path d="M5.394 6.813l1.414-1.415l3.506 3.506L8.9 10.318z" fill="currentColor"></path><path d="M2 15.005h5v2H2z" fill="currentColor"></path><path d="M5.394 25.197L8.9 21.691l1.414 1.415l-3.506 3.505z" fill="currentColor"></path><path d="M15 25.005h2v5h-2z" fill="currentColor"></path><path d="M21.687 23.106l1.414-1.415l3.506 3.506l-1.414 1.414z" fill="currentColor"></path><path d="M25 15.005h5v2h-5z" fill="currentColor"></path><path d="M21.687 8.904l3.506-3.506l1.414 1.415l-3.506 3.505z" fill="currentColor"></path><path d="M15 2.005h2v5h-2z" fill="currentColor"></path></svg><svg style="display:none;" class="icon" focusable="false" viewBox="0 0 32 32"><path d="M13.502 5.414a15.075 15.075 0 0 0 11.594 18.194a11.113 11.113 0 0 1-7.975 3.39c-.138 0-.278.005-.418 0a11.094 11.094 0 0 1-3.2-21.584M14.98 3a1.002 1.002 0 0 0-.175.016a13.096 13.096 0 0 0 1.825 25.981c.164.006.328 0 .49 0a13.072 13.072 0 0 0 10.703-5.555a1.01 1.01 0 0 0-.783-1.565A13.08 13.08 0 0 1 15.89 4.38A1.015 1.015 0 0 0 14.98 3z" fill="currentColor"></path></svg></button><form class="search-box" role="search"><input type="search" autocomplete="off" spellcheck="false" value><!----></form></div></header><!--]--><div class="sidebar-mask"></div><!--[--><aside class="sidebar"><nav class="navbar-items"><!--[--><div class="navbar-item"><div class="navbar-dropdown-wrapper"><button class="navbar-dropdown-title" type="button" aria-label="前端"><span class="title">前端</span><span class="arrow down"></span></button><button class="navbar-dropdown-title-mobile" type="button" aria-label="前端"><span class="title">前端</span><span class="right arrow"></span></button><ul style="display:none;" class="navbar-dropdown"><!--[--><li class="navbar-dropdown-item"><!--[--><h4 class="navbar-dropdown-subtitle"><span>基础知识</span></h4><ul class="navbar-dropdown-subitem-wrapper"><!--[--><li class="navbar-dropdown-subitem"><a aria-current="page" href="/preview/dev-edge/frontend/html/" class="router-link-active router-link-exact-active router-link-active" aria-label="html"><!--[--><!--]--> html <!--[--><!--]--></a></li><li class="navbar-dropdown-subitem"><a href="/preview/dev-edge/frontend/css/" class="" aria-label="css"><!--[--><!--]--> css <!--[--><!--]--></a></li><li class="navbar-dropdown-subitem"><a href="/preview/dev-edge/frontend/javascript/" class="" aria-label="Javascript"><!--[--><!--]--> Javascript <!--[--><!--]--></a></li><!--]--></ul><!--]--></li><li class="navbar-dropdown-item"><!--[--><h4 class="navbar-dropdown-subtitle"><span>高级进阶</span></h4><ul class="navbar-dropdown-subitem-wrapper"><!--[--><li class="navbar-dropdown-subitem"><a href="/preview/dev-edge/frontend/vue/" class="" aria-label="Vue"><!--[--><!--]--> Vue <!--[--><!--]--></a></li><!--]--></ul><!--]--></li><li class="navbar-dropdown-item"><!--[--><h4 class="navbar-dropdown-subtitle"><span>插件及组件库</span></h4><ul class="navbar-dropdown-subitem-wrapper"><!--[--><li class="navbar-dropdown-subitem"><a href="/preview/dev-edge/frontend/libs/" class="" aria-label="导航"><!--[--><!--]--> 导航 <!--[--><!--]--></a></li><!--]--></ul><!--]--></li><li class="navbar-dropdown-item"><!--[--><h4 class="navbar-dropdown-subtitle"><span>综合</span></h4><ul class="navbar-dropdown-subitem-wrapper"><!--[--><li class="navbar-dropdown-subitem"><a href="/preview/dev-edge/frontend/others/standard" class="" aria-label="前端开发规范"><!--[--><!--]--> 前端开发规范 <!--[--><!--]--></a></li><li class="navbar-dropdown-subitem"><a href="/preview/dev-edge/frontend/others/note" class="" aria-label="前端知识点"><!--[--><!--]--> 前端知识点 <!--[--><!--]--></a></li><!--]--></ul><!--]--></li><!--]--></ul></div></div><div class="navbar-item"><div class="navbar-dropdown-wrapper"><button class="navbar-dropdown-title" type="button" aria-label="后端"><span class="title">后端</span><span class="arrow down"></span></button><button class="navbar-dropdown-title-mobile" type="button" aria-label="后端"><span class="title">后端</span><span class="right arrow"></span></button><ul style="display:none;" class="navbar-dropdown"><!--[--><li class="navbar-dropdown-item"><a href="/preview/dev-edge/backend/java/" class="" aria-label="java"><!--[--><!--]--> java <!--[--><!--]--></a></li><li class="navbar-dropdown-item"><a href="/preview/dev-edge/backend/python/" class="" aria-label="python"><!--[--><!--]--> python <!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-item"><a href="/preview/dev-edge/storage/" class="" aria-label="版本库"><!--[--><!--]--> 版本库 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/preview/dev-edge/manage/" class="" aria-label="管理"><!--[--><!--]--> 管理 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/preview/dev-edge/project/" class="" aria-label="项目"><!--[--><!--]--> 项目 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/preview/dev-edge/system/" class="" aria-label="系统"><!--[--><!--]--> 系统 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/preview/dev-edge/share/" class="" aria-label="分享"><!--[--><!--]--> 分享 <!--[--><!--]--></a></div><div class="navbar-item"><a class="external-link" href="https://gitee.com/chengmaofeng/dev-edge" rel="noopener noreferrer" target="_blank" aria-label="Gitee"><!--[--><!--]--> Gitee <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span><!--[--><!--]--></a></div><!--]--></nav><!--[--><!--]--><ul class="sidebar-items"><!--[--><li><p tabindex="0" class="sidebar-item sidebar-heading active collapsible">基础知识 <span class="down arrow"></span></p><ul style="" class="sidebar-item-children"><!--[--><li><a aria-current="page" href="/preview/dev-edge/frontend/html/" class="router-link-active router-link-exact-active router-link-active sidebar-item active" aria-label="HTML基础知识"><!--[--><!--]--> HTML基础知识 <!--[--><!--]--></a><ul style="" class="sidebar-item-children"><!--[--><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#html基础知识-1" class="router-link-active router-link-exact-active sidebar-item" aria-label="html基础知识"><!--[--><!--]--> html基础知识 <!--[--><!--]--></a><ul style="" class="sidebar-item-children"><!--[--><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#html是什么" class="router-link-active router-link-exact-active sidebar-item" aria-label="html是什么？"><!--[--><!--]--> html是什么？ <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#html的历史" class="router-link-active router-link-exact-active sidebar-item" aria-label="html的历史"><!--[--><!--]--> html的历史 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#html的版本" class="router-link-active router-link-exact-active sidebar-item" aria-label="html的版本"><!--[--><!--]--> html的版本 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#html的基本结构" class="router-link-active router-link-exact-active sidebar-item" aria-label="html的基本结构"><!--[--><!--]--> html的基本结构 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#常用的html标签" class="router-link-active router-link-exact-active sidebar-item" aria-label="常用的html标签"><!--[--><!--]--> 常用的html标签 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#常用属性" class="router-link-active router-link-exact-active sidebar-item" aria-label="常用属性"><!--[--><!--]--> 常用属性 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#html中的注释" class="router-link-active router-link-exact-active sidebar-item" aria-label="html中的注释"><!--[--><!--]--> html中的注释 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#html元素和标签的区别" class="router-link-active router-link-exact-active sidebar-item" aria-label="html元素和标签的区别"><!--[--><!--]--> html元素和标签的区别 <!--[--><!--]--></a><!----></li><!--]--></ul></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#html文本格式化" class="router-link-active router-link-exact-active sidebar-item" aria-label="html文本格式化"><!--[--><!--]--> html文本格式化 <!--[--><!--]--></a><ul style="" class="sidebar-item-children"><!--[--><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#标题和段落" class="router-link-active router-link-exact-active sidebar-item" aria-label="标题和段落"><!--[--><!--]--> 标题和段落 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#粗体和斜体" class="router-link-active router-link-exact-active sidebar-item" aria-label="粗体和斜体"><!--[--><!--]--> 粗体和斜体 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#下划线和删除线" class="router-link-active router-link-exact-active sidebar-item" aria-label="下划线和删除线"><!--[--><!--]--> 下划线和删除线 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#超链接" class="router-link-active router-link-exact-active sidebar-item" aria-label="超链接"><!--[--><!--]--> 超链接 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#图像标签" class="router-link-active router-link-exact-active sidebar-item" aria-label="图像标签"><!--[--><!--]--> 图像标签 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#列表标签" class="router-link-active router-link-exact-active sidebar-item" aria-label="列表标签"><!--[--><!--]--> 列表标签 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#表格标签" class="router-link-active router-link-exact-active sidebar-item" aria-label="表格标签"><!--[--><!--]--> 表格标签 <!--[--><!--]--></a><!----></li><!--]--></ul></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#html表单" class="router-link-active router-link-exact-active sidebar-item" aria-label="html表单"><!--[--><!--]--> html表单 <!--[--><!--]--></a><ul style="" class="sidebar-item-children"><!--[--><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#表单标签" class="router-link-active router-link-exact-active sidebar-item" aria-label="表单标签"><!--[--><!--]--> 表单标签 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#文本框、密码框和多行文本框" class="router-link-active router-link-exact-active sidebar-item" aria-label="文本框、密码框和多行文本框"><!--[--><!--]--> 文本框、密码框和多行文本框 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#单选框和复选框" class="router-link-active router-link-exact-active sidebar-item" aria-label="单选框和复选框"><!--[--><!--]--> 单选框和复选框 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#下拉列表框和列表框" class="router-link-active router-link-exact-active sidebar-item" aria-label="下拉列表框和列表框"><!--[--><!--]--> 下拉列表框和列表框 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#按钮和图像按钮" class="router-link-active router-link-exact-active sidebar-item" aria-label="按钮和图像按钮"><!--[--><!--]--> 按钮和图像按钮 <!--[--><!--]--></a><!----></li><!--]--></ul></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#html高级特性" class="router-link-active router-link-exact-active sidebar-item" aria-label="html高级特性"><!--[--><!--]--> html高级特性 <!--[--><!--]--></a><ul style="" class="sidebar-item-children"><!--[--><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#html语义化" class="router-link-active router-link-exact-active sidebar-item" aria-label="html语义化"><!--[--><!--]--> html语义化 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#框架和iframe" class="router-link-active router-link-exact-active sidebar-item" aria-label="框架和iframe"><!--[--><!--]--> 框架和iframe <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#音频和视频" class="router-link-active router-link-exact-active sidebar-item" aria-label="音频和视频"><!--[--><!--]--> 音频和视频 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#canvas绘图" class="router-link-active router-link-exact-active sidebar-item" aria-label="canvas绘图"><!--[--><!--]--> canvas绘图 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#svg图像" class="router-link-active router-link-exact-active sidebar-item" aria-label="svg图像"><!--[--><!--]--> svg图像 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/preview/dev-edge/frontend/html/#web存储技术" class="router-link-active router-link-exact-active sidebar-item" aria-label="web存储技术"><!--[--><!--]--> web存储技术 <!--[--><!--]--></a><!----></li><!--]--></ul></li><!--]--></ul></li><li><a href="/preview/dev-edge/frontend/css/" class="sidebar-item" aria-label="CSS知识点"><!--[--><!--]--> CSS知识点 <!--[--><!--]--></a><!----></li><li><a href="/preview/dev-edge/frontend/javascript/" class="sidebar-item" aria-label="Javascript"><!--[--><!--]--> Javascript <!--[--><!--]--></a><!----></li><!--]--></ul></li><li><p tabindex="0" class="sidebar-item sidebar-heading collapsible">高级进阶 <span class="right arrow"></span></p><ul style="display:none;" class="sidebar-item-children"><!--[--><li><a href="/preview/dev-edge/frontend/vue/" class="sidebar-item" aria-label="Vue"><!--[--><!--]--> Vue <!--[--><!--]--></a><!----></li><!--]--></ul></li><li><p tabindex="0" class="sidebar-item sidebar-heading collapsible">插件及组件库 <span class="right arrow"></span></p><ul style="display:none;" class="sidebar-item-children"><!--[--><li><a href="/preview/dev-edge/frontend/libs/" class="sidebar-item" aria-label="插件及组件库"><!--[--><!--]--> 插件及组件库 <!--[--><!--]--></a><!----></li><li><a href="/preview/dev-edge/frontend/libs/element.html" class="sidebar-item" aria-label="element UI 快捷代码片段记录"><!--[--><!--]--> element UI 快捷代码片段记录 <!--[--><!--]--></a><!----></li><li><a href="/preview/dev-edge/frontend/libs/others.html" class="sidebar-item" aria-label="其他"><!--[--><!--]--> 其他 <!--[--><!--]--></a><!----></li><!--]--></ul></li><li><p tabindex="0" class="sidebar-item sidebar-heading collapsible">综合 <span class="right arrow"></span></p><ul style="display:none;" class="sidebar-item-children"><!--[--><li><a href="/preview/dev-edge/frontend/others/standard.html" class="sidebar-item" aria-label="前端开发规范"><!--[--><!--]--> 前端开发规范 <!--[--><!--]--></a><!----></li><li><a href="/preview/dev-edge/frontend/others/note.html" class="sidebar-item" aria-label="前端知识点"><!--[--><!--]--> 前端知识点 <!--[--><!--]--></a><!----></li><!--]--></ul></li><!--]--></ul><!--[--><!--]--></aside><!--]--><!--[--><main class="page"><!--[--><!--]--><div class="theme-default-content"><!--[--><!--]--><div><h1 id="html基础知识" tabindex="-1"><a class="header-anchor" href="#html基础知识" aria-hidden="true">#</a> HTML基础知识</h1><h2 id="html基础知识-1" tabindex="-1"><a class="header-anchor" href="#html基础知识-1" aria-hidden="true">#</a> html基础知识</h2><h3 id="html是什么" tabindex="-1"><a class="header-anchor" href="#html是什么" aria-hidden="true">#</a> html是什么？</h3><p>TML代表“超文本标记语言”，其中“超文本”指的是文本中包含的链接和其他媒体元素，例如图像和视频。</p><p>HTML使用标记或标签来定义文档的结构和内容，并使用属性来指定标记的特定属性和值。</p><h3 id="html的历史" tabindex="-1"><a class="header-anchor" href="#html的历史" aria-hidden="true">#</a> html的历史</h3><p>HTML的历史可以追溯到20世纪80年代早期，当时欧洲核子研究组织（CERN）的一些研究人员开始探索一种新的方式来共享文档和信息。这些研究人员中的一位，蒂姆·伯纳斯-李（Tim Berners-Lee），最终开发出了HTML和其他相关技术，如HTTP和URL，以创建Web。</p><p>HTML最初的版本非常简单，只包含一些基本的标记和属性。随着Web的发展，HTML也不断发展和演变，新的标记和属性被添加到语言中，以支持更复杂的Web应用程序和功能。目前，最新版本的HTML是HTML5，它包含许多新的功能和API，如视频和音频支持、本地存储、Web Workers和Web Sockets等。</p><p>总之，HTML是Web开发的基础，它使用标记和属性来定义文档的结构和内容。HTML的历史可以追溯到20世纪80年代早期，当时欧洲核子研究组织的一些研究人员开始探索一种新的方式来共享文档和信息。随着Web的发展，HTML也不断发展和演变，新的标记和属性被添加到语言中，以支持更复杂的Web应用程序和功能。</p><h3 id="html的版本" tabindex="-1"><a class="header-anchor" href="#html的版本" aria-hidden="true">#</a> html的版本</h3><p>HTML有许多版本，最新版本是HTML5。HTML最初的版本非常简单，只包含一些基本的标记和属性。</p><p>随着Web的发展，HTML也不断发展和演变，新的标记和属性被添加到语言中，以支持更复杂的Web应用程序和功能</p><h3 id="html的基本结构" tabindex="-1"><a class="header-anchor" href="#html的基本结构" aria-hidden="true">#</a> html的基本结构</h3><p>一个HTML文档由以下几部分组成：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token doctype"><span class="token punctuation">&lt;!</span><span class="token doctype-tag">DOCTYPE</span> <span class="token name">html</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>html</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>head</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">charset</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>utf-8<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>title</span><span class="token punctuation">&gt;</span></span>页面标题<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>title</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">&gt;</span></span>
    页面内容
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>html</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><ul><li><code>&lt;!DOCTYPE html&gt;</code> 声明文档类型为HTML5。</li><li><code>&lt;html&gt;</code> 元素是整个文档的根元素。</li><li><code>&lt;head&gt;</code> 元素包含了文档的元数据，如页面标题、关键字等信息。</li><li><code>&lt;meta&gt;</code> 元素定义了文档的字符编码、显示方式等信息。</li><li><code>&lt;title&gt;</code> 元素定义了页面标题，将会显示在浏览器的标题栏上。</li><li><code>&lt;body&gt;</code> 元素包含了页面的主要内容。</li></ul><h3 id="常用的html标签" tabindex="-1"><a class="header-anchor" href="#常用的html标签" aria-hidden="true">#</a> 常用的html标签</h3><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>- &lt;h1&gt;到6&gt;：用于表示标题。1&gt;是最高级别的标题，6&gt;是最低级别的标题。
- &lt;p&gt;：用于表示段落。
- &lt;a&gt;：用于表示链接。&gt;标签需要一个href属性，该属性指定链接的URL。
- &lt;img&gt;：用于表示图像。&gt;标签需要一个src属性，该属性指定图像的URL。
- &lt;ul&gt;和&lt;ol&gt;：用于表示无序列表和有序列表。
- &lt;li&gt;：用于表示列表项。
- &lt;table&gt;：用于表示表格。
- &lt;tr&gt;：用于表示表格行。
- &lt;td&gt;：用于表示表格单元格。
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="常用属性" tabindex="-1"><a class="header-anchor" href="#常用属性" aria-hidden="true">#</a> 常用属性</h3><p>以下是一些常用的HTML属性：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>- class：用于指定元素的类。类通常用于指定元素的样式。
- id：用于指定元素的唯一标识符。ID通常用于JavaScript和CSS中。
- href：用于指定链接的URL。
- src：用于指定图像的URL。
- alt：用于指定图像的替代文本。如果图像无法加载，替代文本将显示在其位置上。
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="html中的注释" tabindex="-1"><a class="header-anchor" href="#html中的注释" aria-hidden="true">#</a> html中的注释</h3><p>使用注释可以在代码中添加一些解释性的文字，而这些文字不会被浏览器渲染。 在HTML中，注释的语法如下：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token comment">&lt;!-- 注释内容 --&gt;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="html元素和标签的区别" tabindex="-1"><a class="header-anchor" href="#html元素和标签的区别" aria-hidden="true">#</a> html元素和标签的区别</h3><p>HTML元素和标签是两个不同的概念。</p><p>HTML元素是指从开始标签到结束标签之间的所有内容，包括标签本身、标签属性和标签内容</p><p>HTML标签则是用于定义HTML元素的名称，通常由尖括号包围<code>&lt; &gt;</code></p><h2 id="html文本格式化" tabindex="-1"><a class="header-anchor" href="#html文本格式化" aria-hidden="true">#</a> html文本格式化</h2><h3 id="标题和段落" tabindex="-1"><a class="header-anchor" href="#标题和段落" aria-hidden="true">#</a> 标题和段落</h3><p>HTML提供了六个级别的标题，从<code>&lt;h1&gt;</code>到<code>&lt;h6&gt;</code>。</p><p><code>&lt;h1&gt;</code>标记用于页面上最重要的标题，而<code>&lt;h6&gt;</code>标记用于最不重要的标题。 以下是如何使用<code>&lt;h1&gt;</code>标记创建顶级标题的示例：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">&gt;</span></span>This is a top-level heading.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>要用HTML创建一个段落，可以使用<code>&lt;p&gt;</code>标记。 段落的实际内容将被放置在开始和结束<code>&lt;p&gt;</code>标签之间，如下所示：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>This is a paragraph of text.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="粗体和斜体" tabindex="-1"><a class="header-anchor" href="#粗体和斜体" aria-hidden="true">#</a> 粗体和斜体</h3><p>要使HTML中的文本加粗，可以使用<code>&lt;strong&gt;</code>标记或<code>&lt;b&gt;</code>标记。</p><p>这两个标记都用于指示所包含的文本应以粗体显示。</p><p>这两个标签的区别在于，<code>&lt;strong&gt;</code>用于表示文本非常重要，而<code>&lt;b&gt;</code>用于表示出于风格目的，文本只是粗体。</p><p>以下是如何使用<code>&lt;strong&gt;</code>标记将文本加粗的示例：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>strong</span><span class="token punctuation">&gt;</span></span>This text is bold.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>strong</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>要使HTML中的文本变为斜体，可以使用<code>&lt;em&gt;</code>标记或<code>&lt;i&gt;</code>标记。 这两个标记都用于指示所包含的文本应以斜体显示。</p><p>这两个标签之间的差异类似于<code>&lt;strong&gt;</code>和<code>&lt;b&gt;</code>之间的差异<code>&lt;em&gt;</code>用于表示文本是强调的，而<code>&lt;i&gt;</code>用于表示出于风格目的，文本只是斜体。</p><p>以下是如何使用<code>&lt;em&gt;</code>标记使文本变为斜体的示例：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>em</span><span class="token punctuation">&gt;</span></span>This text is italic.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>em</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="下划线和删除线" tabindex="-1"><a class="header-anchor" href="#下划线和删除线" aria-hidden="true">#</a> 下划线和删除线</h3><p>要在HTML中给文本加下划线，可以使用值为underline的CSS文本装饰属性。下面是一个例子：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span> <span class="token special-attr"><span class="token attr-name">style</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span><span class="token value css language-css"><span class="token property">text-decoration</span><span class="token punctuation">:</span> underline<span class="token punctuation">;</span></span><span class="token punctuation">&quot;</span></span></span><span class="token punctuation">&gt;</span></span>This text is underlined.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>要在HTML中创建删除线文本，可以使用值为line-through的CSS文本装饰属性。下面是一个例子：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span> <span class="token special-attr"><span class="token attr-name">style</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span><span class="token value css language-css"><span class="token property">text-decoration</span><span class="token punctuation">:</span> line-through<span class="token punctuation">;</span></span><span class="token punctuation">&quot;</span></span></span><span class="token punctuation">&gt;</span></span>This text has a strikethrough.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="超链接" tabindex="-1"><a class="header-anchor" href="#超链接" aria-hidden="true">#</a> 超链接</h3><p>您可以使用<code>&lt;a&gt;</code>标记在HTML中创建超链接。href属性指定链接应指向的URL。以下是一个示例：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>https://www.example.com<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>This is a hyperlink.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="图像标签" tabindex="-1"><a class="header-anchor" href="#图像标签" aria-hidden="true">#</a> 图像标签</h3><p>对于图像，可以使用<code>&lt;img&gt;</code>标记。src属性指定图像文件的URL，alt属性为看不到图像的用户提供替代文本。下面是一个例子：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>path/to/image.jpg<span class="token punctuation">&quot;</span></span> <span class="token attr-name">alt</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>This is an image.<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="列表标签" tabindex="-1"><a class="header-anchor" href="#列表标签" aria-hidden="true">#</a> 列表标签</h3><p>对于列表，HTML提供了几个标记，包括用于无序列表的<code>&lt;ul&gt;</code>和用于有序列表的<code>&lt;ol&gt;</code>。下面是一个无序列表的例子：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>ul</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span>Item 1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span>Item 2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span>Item 3<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>ul</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>下面是一个有序列表的例子：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>ol</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span>First item<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span>Second item<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>li</span><span class="token punctuation">&gt;</span></span>Third item<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>li</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>ol</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="表格标签" tabindex="-1"><a class="header-anchor" href="#表格标签" aria-hidden="true">#</a> 表格标签</h3><p>您可以使用<code>&lt;table&gt;</code>标记。在表中，可以使用<code>&lt;tr&gt;</code>标记定义行，使用<code>&lt;td&gt;</code>标记定义每行中的单元格。下面是一个例子：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>table</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>tr</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>td</span><span class="token punctuation">&gt;</span></span>Row 1, Column 1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>td</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>td</span><span class="token punctuation">&gt;</span></span>Row 1, Column 2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>td</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>tr</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>tr</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>td</span><span class="token punctuation">&gt;</span></span>Row 2, Column 1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>td</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>td</span><span class="token punctuation">&gt;</span></span>Row 2, Column 2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>td</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>tr</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>table</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="html表单" tabindex="-1"><a class="header-anchor" href="#html表单" aria-hidden="true">#</a> html表单</h2><h3 id="表单标签" tabindex="-1"><a class="header-anchor" href="#表单标签" aria-hidden="true">#</a> 表单标签</h3><p>HTML提供了几个用于创建表单的标签，包括<code>&lt;form&gt;</code>、<code>&lt;input&gt;</code>、<code>&lt;label&gt;</code>、<code>&lt;select&gt;</code>、<code>&lt;option&gt;</code>、<code>&lt;textarea&gt;</code>和<code>&lt;button&gt;</code>。</p><p><code>&lt;form&gt;</code>标记用于创建表单元素，该元素可以包含一个或多个表单控件，如文本输入、复选框、单选按钮等。</p><p>action属性指定表单数据应提交到的URL，method属性指定用于提交的HTTP方法（通常为“GET”或“POST”）。</p><p>下面是一个带有文本输入和提交按钮的简单表单示例：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>form</span> <span class="token attr-name">action</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>submit-form.php<span class="token punctuation">&quot;</span></span> <span class="token attr-name">method</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>POST<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span> <span class="token attr-name">for</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>name<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>Name:<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>text<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>name<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>name<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>submit<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>button</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>form</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>在本例中，<code>&lt;label&gt;</code>标记用于使用for属性和id属性将文本输入与其标签相关联。输入的name属性指定将与表单数据一起提交的表单字段的名称。</p><p><code>&lt;select&gt;</code>标记用于创建选项的下拉列表，<code>&lt;option＞</code>标记用于定义每个选项。下面是一个例子：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span> <span class="token attr-name">for</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>color<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>Favorite color:<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>select</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>color<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>color<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>red<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>Red<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>green<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>Green<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>blue<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>Blue<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>select</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>在本例中，每个选项的value属性指定将与表单数据一起提交的值。</p><p><code>&lt;textarea&gt;</code>标记用于创建多行文本输入。下面是一个例子：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span> <span class="token attr-name">for</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>message<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>Message:<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>textarea</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>message<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>message<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>textarea</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p><code>＜button＞</code>标记用于创建一个按钮，该按钮可用于提交表单或执行其他操作。 下面是一个例子：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>submit<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>button</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="文本框、密码框和多行文本框" tabindex="-1"><a class="header-anchor" href="#文本框、密码框和多行文本框" aria-hidden="true">#</a> 文本框、密码框和多行文本框</h3><p>HTML中，文本框、密码框和多行文本框分别使用input元素的不同type属性值来实现。</p><ul><li>文本框：使用<code>&lt;input type=&quot;text&quot;&gt;</code>标签实现；</li><li>密码框：使用<code>&lt;input type=&quot;password&quot;&gt;</code>标签实现；</li><li>多行文本框：使用<code>&lt;textarea&gt;&lt;/textarea&gt;</code>标签实现。</li></ul><p>文本框、密码框和多行文本框是用来接收用户输入的常见表单元素。它们分别使用不同的标签和属性来实现。</p><ol><li>文本框</li></ol><p>文本框（text box）是用于接受单行文本输入的表单元素。可以通过设置<code>&lt;input&gt;</code>标签的<code>type</code>属性为&quot;text&quot;来创建文本框。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span> <span class="token attr-name">for</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>username<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>用户名：<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>text<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>username<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>username<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>上面的示例代码中，<code>id</code>属性定义了文本框的唯一标识符，<code>name</code>属性定义了提交表单时该文本框的名称。</p><ol start="2"><li>密码框</li></ol><p>密码框（password field）是用于接受密码等敏感信息的表单元素，并且会将用户输入的字符隐藏起来。可以通过设置<code>&lt;input&gt;</code>标签的<code>type</code>属性为&quot;password&quot;来创建密码框。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span> <span class="token attr-name">for</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>password<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>密码：<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>password<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>password<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>password<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><ol start="3"><li>多行文本框</li></ol><p>多行文本框（text area）可用于接收包含多个行的文本输入，例如评论或留言等。可以通过使用<code>&lt;textarea&gt;</code>标签来创建多行文本框，然后使用它的<code>rows</code>和<code>cols</code>属性来指定它的尺寸。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span> <span class="token attr-name">for</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>message<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>留言：<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>textarea</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>message<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>message<span class="token punctuation">&quot;</span></span> <span class="token attr-name">rows</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>5<span class="token punctuation">&quot;</span></span> <span class="token attr-name">cols</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>30<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>textarea</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>上面的示例代码中，<code>rows</code>属性定义了多行文本框的行数，<code>cols</code>属性定义了多行文本框每一行的字符数。</p><h3 id="单选框和复选框" tabindex="-1"><a class="header-anchor" href="#单选框和复选框" aria-hidden="true">#</a> 单选框和复选框</h3><p>HTML中，单选框和复选框是常见的表单元素，用于让用户选择不同选项。它们分别使用<code>&lt;input&gt;</code>标签的不同<code>type</code>属性值来实现。</p><ol><li>单选框</li></ol><p>单选框（radio button）允许用户在一组选项中选择一个。可以使用相同的<code>name</code>属性来将多个单选框关联起来。当用户勾选其中一个单选框时，其他单选框将自动取消选中状态。可以通过设置<code>&lt;input&gt;</code>标签的<code>type</code>属性为&quot;radio&quot;来创建单选框。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>form</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>请选择性别：<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>radio<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>gender<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>M<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>男士<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>radio<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>gender<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>F<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>女士<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>radio<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>gender<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>O<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>其他<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>form</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>上面的示例代码中，三个单选框使用相同的<code>name</code>属性，以便将它们关联起来。当用户勾选其中一个单选框时，另外两个单选框将自动取消选中状态。</p><ol start="2"><li>复选框</li></ol><p>复选框（checkbox）允许用户选择多个选项。可以使用相同的<code>name</code>属性来将多个复选框关联起来。当用户勾选其中一个复选框时，其他复选框保持不变。可以通过设置<code>&lt;input&gt;</code>标签的<code>type</code>属性为&quot;checkbox&quot;来创建复选框。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>form</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>请选择语言：<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>checkbox<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>lang<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>js<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>JavaScript<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>checkbox<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>lang<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>py<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>Python<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>checkbox<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>lang<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>java<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>Java<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>form</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>上面的示例代码中，三个复选框使用相同的<code>name</code>属性，以便将它们关联起来。用户可以勾选多个复选框。</p><p>单选框和复选框的值可以通过<code>value</code>属性进行指定，当表单提交时，浏览器会将被选中的单选框或复选框的值作为表单数据提交到服务器并进行处理。</p><h3 id="下拉列表框和列表框" tabindex="-1"><a class="header-anchor" href="#下拉列表框和列表框" aria-hidden="true">#</a> 下拉列表框和列表框</h3><p>HTML中，下拉列表框和列表框是用来显示多个选项的表单元素。它们分别使用不同的标签和属性来实现。</p><ol><li>下拉列表框</li></ol><p>下拉列表框（dropdown list）可以让用户从多个选项中选择一个选项。可以使用<code>&lt;select&gt;</code>标签来创建下拉列表框，然后使用<code>&lt;option&gt;</code>标签定义每一个选项。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>form</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>请选择城市：<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>select</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>city<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>bj<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>北京<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>sh<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>上海<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>gz<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>广州<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>sz<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>深圳<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>select</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>form</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>上面的示例代码中，四个<code>&lt;option&gt;</code>标签定义了四个选项。其中&quot;value&quot;属性指定每个选项的值，&quot;text&quot;节点指定每个选项的文本内容。当用户点击下拉框时，会出现一个下拉菜单列出所有可用选项，用户可以从中选择一个选项。</p><ol start="2"><li>列表框</li></ol><p>列表框（list box）是另一种显示多个选项的表单元素，与下拉列表框不同的是，列表框可以同时显示多个选项。可以使用<code>&lt;select&gt;</code>标签来创建列表框，然后使用<code>&lt;option&gt;</code>标签定义每一个选项并设置<code>multiple</code>属性为&quot;multiple&quot;来启用多选模式。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>form</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>请选择兴趣爱好：<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>select</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>interests<span class="token punctuation">&quot;</span></span> <span class="token attr-name">multiple</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>reading<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>阅读<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>music<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>音乐<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>painting<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>绘画<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>sports<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>运动<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>select</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>form</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>上面的示例代码中，<code>multiple</code>属性指定该列表框启用多选模式。当用户选择一个或多个选项时，这些选项将被高亮显示。</p><p>总之，在HTML中可以使用下拉列表框和列表框来为用户提供多个选项让用户选择，并在表单提交时将选择的结果作为表单数据提交到服务器。</p><h3 id="按钮和图像按钮" tabindex="-1"><a class="header-anchor" href="#按钮和图像按钮" aria-hidden="true">#</a> 按钮和图像按钮</h3><p>HTML中，按钮和图像按钮是用来触发事件或提交表单的表单元素。它们分别使用<code>&lt;button&gt;</code>标签和<code>&lt;input&gt;</code>标签的不同type属性值来实现。</p><ol><li>普通按钮</li></ol><p>普通按钮（button）通常用于触发一些事件，例如刷新页面、清空表单等。可以使用<code>&lt;button&gt;</code>标签来创建普通按钮。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span><span class="token punctuation">&gt;</span></span>点击我<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>button</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>上面的示例代码中，创建了一个简单的按钮，点击按钮会触发一些事件。</p><ol start="2"><li>提交按钮</li></ol><p>提交按钮（submit button）用于将表单数据提交到服务器进行处理。可以使用<code>&lt;input&gt;</code>标签，并将其type属性设置为&quot;submit&quot;来创建提交按钮，例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>submit<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>提交<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>上面的示例代码中，设置了一个提交按钮，当用户点击该按钮时，浏览器会将表单数据提交到服务器并进行处理。</p><ol start="3"><li>图像按钮</li></ol><p>图像按钮（image button）与普通按钮类似，但它使用图片而不是文本作为按钮的标识。可以使用<code>&lt;input&gt;</code>标签，并将其type属性设置为&quot;image&quot;来创建图像按钮，例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>image<span class="token punctuation">&quot;</span></span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>submit.png<span class="token punctuation">&quot;</span></span> <span class="token attr-name">alt</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>提交<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>上面的示例代码中，创建了一个带有图片的图像按钮。当用户单击图像按钮时，浏览器会将表单数据提交到服务器并进行处理。</p><h2 id="html高级特性" tabindex="-1"><a class="header-anchor" href="#html高级特性" aria-hidden="true">#</a> html高级特性</h2><h3 id="html语义化" tabindex="-1"><a class="header-anchor" href="#html语义化" aria-hidden="true">#</a> html语义化</h3><p>html语义化是指在编写html代码时，使用具有语义意义的元素来描述网页内容的结构、属性和功能等。</p><p>这种做法不仅可以使页面结构更加清晰，易于维护， 而且能够让搜索引擎更好地理解页面内容，提高页面的可访问性。</p><p>以下是一些常用的html元素和它们的语义含义：</p><ul><li><code>&lt;header&gt;</code>：表示网页或文章的标题、导航栏等主要内容。</li><li><code>&lt;nav&gt;</code>：表示导航菜单栏。</li><li><code>&lt;main&gt;</code>：表示页面主体部分的内容，通常是一个单独的区块。</li><li><code>&lt;section&gt;</code>：表示文档中一个**的区域，通常包含一个头部和一个相关内容的块级元素。</li><li><code>&lt;article&gt;</code>：表示即便被拆开阅读，也能单独存在或者被嵌入其他文档的内容。</li><li><code>&lt;aside&gt;</code>：表示页面内容的附属信息或服务，通常作为侧边栏。</li><li><code>&lt;footer&gt;</code>：表示网页尾部信息，如版权声明、联系方式等。</li></ul><p>除此之外，还有一些表达特定意义的html元素，例如：</p><ul><li><code>&lt;h1&gt;-&lt;h6&gt;</code>：表示标题，编号从1到6，其中<code>&lt;h1&gt;</code>是最高等级的标题。</li><li><code>&lt;p&gt;</code>：表示段落</li><li><code>&lt;em&gt;</code>：表示强调文本，将文本以斜体的形式展示。</li><li><code>&lt;strong&gt;</code>：表示重要性文本，将文本以加粗的形式展示。</li><li><code>&lt;time&gt;</code>：表示日期或时间</li><li><code>&lt;figure&gt;</code>：表示一组相关联的多媒体内容和它们的标题。 通过合理利用这些具有语义含义的html元素，我们可以更清楚地表达网页内容的结构和意义。</li></ul><p>html语义化的优点</p><ol><li>有利于seo：搜索引擎爬虫可以更好地理解页面结构，提高网站的排名。</li><li>提高可读性：标签的含义更清晰，能够更容易地理解网页结构。</li><li>方便开发维护：更具有可读性和</li></ol><h3 id="框架和iframe" tabindex="-1"><a class="header-anchor" href="#框架和iframe" aria-hidden="true">#</a> 框架和iframe</h3><p>HTML中，框架和iframe都是用于在一个页面中嵌入另一个页面的方式。它们具有不同的使用方法和特点，请参考以下详细介绍。</p><ol><li>框架（frameset）</li></ol><p>框架是一种比较古老的技术，它可以将一个网页分割为多个窗口（frame），每个窗口可以独立加载不同的HTML文件。框架通常使用<code>&lt;frameset&gt;</code>和<code>&lt;frame&gt;</code>标签来实现。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token doctype"><span class="token punctuation">&lt;!</span><span class="token doctype-tag">DOCTYPE</span> <span class="token name">html</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>html</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>head</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>title</span><span class="token punctuation">&gt;</span></span>框架示例<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>title</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>frameset</span> <span class="token attr-name">rows</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>20%,80%<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>frame</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>header.html<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>frame</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>content.html<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>frameset</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>html</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>上面的示例代码中，使用了frameset标签来定义分割窗口，并使用frame标签指定每个窗口所要显示的HTML文件。</p><p>框架的优点是能够快速刷新其中的一个局部，而不需要完整地重新加载整个页面，从而提高用户体验。但是，由于框架的缺点也显著——此技术已经过时，浏览器支持性较差，且容易造成网站的SEO问题，因此较少在现代Web开发中使用。</p><ol start="2"><li>iframe</li></ol><p>iframe是现代Web开发中常用的页面嵌入技术。它可以将一个页面嵌入到另一个页面中的固定位置，以实现局部更新和交互。可以使用<code>&lt;iframe&gt;</code>标签来创建iframe。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token doctype"><span class="token punctuation">&lt;!</span><span class="token doctype-tag">DOCTYPE</span> <span class="token name">html</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>html</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>head</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>title</span><span class="token punctuation">&gt;</span></span>iframe示例<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>title</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">&gt;</span></span>主页<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>这是首页内容。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>iframe</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>news.html<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>iframe</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>html</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>上面的示例代码中，指定了一个iframe元素并将其src属性设置为要嵌入的HTML文件链接。</p><p>与框架相比，iframe具有更强大的可定制性、灵活性和兼容性，而且也不会对SEO造成负面影响。但是，可能存在与同源策略相关的安全问题，需要开发者进行考虑和防范。</p><p>总之，在HTML中可使用框架和iframe用于在一个页面中嵌入另一个页面。但是，由于框架技术已经过时，较少使用；iframe则常见于现代Web开发中。需要根据实际需求进行选择和应用。</p><h3 id="音频和视频" tabindex="-1"><a class="header-anchor" href="#音频和视频" aria-hidden="true">#</a> 音频和视频</h3><p>HTML中，音频和视频是用来在网页中嵌入音频或视频文件的标签。它们分别使用<code>&lt;audio&gt;</code>标签和<code>&lt;video&gt;</code>标签来实现。</p><ol><li>音频（Audio）</li></ol><p>音频可以用来播放音乐、语音等各种音频效果。可以使用<code>&lt;audio&gt;</code>标签来创建音频播放器，并通过src属性指定要播放的音频文件链接。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>audio</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>music.mp3<span class="token punctuation">&quot;</span></span> <span class="token attr-name">controls</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>audio</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>上面的示例代码中，定义了一个音频播放器，通过src属性指定了要播放的音频文件名为&quot;music.mp3&quot;。controls属性可以让浏览器自动添加播放控件，包括播放/暂停、音量调节、快进/快退等。</p><ol start="2"><li>视频（Video）</li></ol><p>视频可以用于播放各种视频内容，例如电影、短片、教学视频等。可以使用<code>&lt;video&gt;</code>标签来创建视频播放器，并通过src属性指定要播放的视频文件链接。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>video</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>movie.mp4<span class="token punctuation">&quot;</span></span> <span class="token attr-name">controls</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>video</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>上面的示例代码中，定义了一个视频播放器，通过src属性指定了要播放的视频文件名为&quot;movie.mp4&quot;。同样，设置了controls属性可以让浏览器自动添加播放控件。</p><p>在使用音频和视频时，可以设置多个属性，包括：autoplay（自动播放）、loop（循环播放）、preload（预加载）、muted（关闭声音），等等。要实现更复杂的功能，可以通过JavaScript来操作音频和视频标签提供的API。</p><p>总之，在HTML中可使用音频和视频标签来嵌入音频或视频文件，并在网页中进行播放、暂停等操作。具体使用方式和属性设置根据需要进行选择和调整。</p><h3 id="canvas绘图" tabindex="-1"><a class="header-anchor" href="#canvas绘图" aria-hidden="true">#</a> canvas绘图</h3><p>HTML中，可以使用Canvas来绘制各种图形。Canvas是一个HTML5标签，它提供了一个由JavaScript控制的画布，可以在其中创建和操作各种图形，例如线条、矩形、圆形、文本等。以下是详细介绍。</p><ol><li>创建Canvas元素</li></ol><p>在HTML页面中，可以使用<code>&lt;canvas&gt;</code>标签来创建画布。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>canvas</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>myCanvas<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>canvas</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>上面的示例代码中，定义了一个id属性为&quot;myCanvas&quot;的Canvas元素。然后可以使用JavaScript获取这个元素，并进行操作。</p><ol start="2"><li>绘制基本图形</li></ol><p>使用Canvas中的API可以绘制各种基本图形，例如线条、矩形、圆形、椭圆等。以下是一些常用的API：</p><ul><li>绘制直线：<code>ctx.moveTo(x,y)</code>和<code>ctx.lineTo(x,y)</code>，其中<code>moveTo()</code>用于设定起点位置，<code>lineTo()</code>用于连接终点位置。</li><li>绘制矩形：<code>ctx.fillStyle=color</code>用于设置填充颜色，<code>ctx.fillRect(x,y,width,height)</code>用于绘制实心矩形。</li><li>绘制圆形：<code>ctx.arc(x,y,radius,startAngle,endAngle,anticlockwise)</code>，其中<code>(x,y)</code>表示圆心坐标，<code>radius</code>表示半径，<code>startAngle</code>和<code>endAngle</code>表示起始角度和结束角度（以弧度为单位），<code>anticlockwise</code>表示是否为逆时针方向绘制。</li><li>绘制文本：<code>ctx.font=font</code>用于设置字体，<code>ctx.fillText(text,x,y)</code>用于绘制实心文本，<code>ctx.strokeText(text,x,y)</code>用于绘制空心文本。</li></ul><ol start="3"><li>为图形添加样式</li></ol><p>可以使用Canvas中的API来为绘制的图形添加颜色、样式等特性。以下是一些常用的API：</p><ul><li>填充颜色：<code>ctx.fillStyle=color</code>，其中color为字符串类型的颜色值（例如&quot;#ff0000&quot;表示红色）。</li><li>描边颜色：<code>ctx.strokeStyle=color</code>，其中color为字符串类型的颜色值。</li><li>描边宽度：<code>ctx.lineWidth=width</code>，其中width为数字类型的描边宽度。</li><li>文本对齐方式：<code>ctx.textAlign=align</code>，其中align为字符串类型的文本对齐方式（例如&quot;center&quot;表示居中对齐）。</li></ul><ol start="4"><li>绘制复杂图形</li></ol><p>使用Canvas的API可以进行各种复杂的绘制操作，例如模拟动画、实现游戏等。可以通过不断更新Canvas中的图形内容，实现各种有趣的图形效果。</p><p>总之，在HTML中可创建Canvas元素，并使用Canvas的API进行各种绘制操作。具体方法和API根据需要进行选择和调整。可以参考官方文档或者相关教程进行学习。</p><h3 id="svg图像" tabindex="-1"><a class="header-anchor" href="#svg图像" aria-hidden="true">#</a> svg图像</h3><p>HTML中，SVG是用来创建基于矢量图形的图像的标准。与位图（例如JPEG、PNG等格式）不同，SVG使用数学公式来描述图形，因此图像可以无限缩放而不会失真。以下是详细介绍。</p><ol><li>创建SVG元素</li></ol><p>在HTML页面中，可以使用<code>&lt;svg&gt;</code>标签来创建SVG元素。例如：</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>svg</span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>200<span class="token punctuation">&quot;</span></span> <span class="token attr-name">height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>200<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>circle</span> <span class="token attr-name">cx</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>100<span class="token punctuation">&quot;</span></span> <span class="token attr-name">cy</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>100<span class="token punctuation">&quot;</span></span> <span class="token attr-name">r</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>50<span class="token punctuation">&quot;</span></span> <span class="token attr-name">fill</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>#ff0000<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>svg</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>上面的示例代码中，定义了一个宽度为200px、高度为200px的SVG元素，并在其中绘制了一个红色圆形。</p><ol start="2"><li>绘制基本图形</li></ol><p>使用SVG可以绘制各种基本图形，例如线条、矩形、圆形、文本等。以下是一些常用的SVG元素：</p><ul><li>直线：<code>&lt;line x1=&quot;x1&quot; y1=&quot;y1&quot; x2=&quot;x2&quot; y2=&quot;y2&quot; stroke=&quot;color&quot; stroke-width=&quot;width&quot; /&gt;</code>，其中<code>(x1,y1)</code>为起点坐标，<code>(x2,y2)</code>为终点坐标，<code>stroke</code>用于设置颜色，<code>stroke-width</code>用于设置线宽。</li><li>矩形：<code>&lt;rect x=&quot;x&quot; y=&quot;y&quot; width=&quot;width&quot; height=&quot;height&quot; fill=&quot;color&quot; stroke=&quot;color&quot; stroke-width=&quot;width&quot; /&gt;</code>，其中<code>(x,y)</code>为左上角坐标，<code>fill</code>用于设置填充颜色，<code>stroke</code>用于设置边框颜色，<code>stroke-width</code>用于设置边框宽度。</li><li>圆形：<code>&lt;circle cx=&quot;cx&quot; cy=&quot;cy&quot; r=&quot;r&quot; fill=&quot;color&quot; stroke=&quot;color&quot; stroke-width=&quot;width&quot; /&gt;</code>，其中<code>(cx,cy)</code>为圆心坐标，<code>r</code>为半径，<code>fill</code>用于设置填充颜色，<code>stroke</code>用于设置边框颜色，<code>stroke-width</code>用于设置边框宽度。</li><li>文本：<code>&lt;text x=&quot;x&quot; y=&quot;y&quot; fill=&quot;color&quot; font-size=&quot;size&quot;&gt;text&lt;/text&gt;</code>，其中<code>(x,y)</code>为文本起点坐标，<code>fill</code>用于设置字体颜色，<code>font-size</code>用于设置字体大小。</li></ul><p>可以通过设置SVG元素的属性，例如<code>&lt;rect&gt;</code>标签的属性来更改图形属性。</p><ol start="3"><li>绘制复杂图形</li></ol><p>SVG还支持各种复杂的绘制操作，例如添加动画、实现交互效果等。可以使用CSS和JavaScript来操作SVG元素，例如使用transition来改变图例样式，或者通过鼠标事件来实现交互效果。</p><p>总之，在HTML中可以使用SVG来创建基于矢量图形的图像，并进行各种绘制操作和样式设置。具体使用方法需要根据需求选择相关API以及工具（比如Adobe Illustrator），并进行实际应用。</p><h3 id="web存储技术" tabindex="-1"><a class="header-anchor" href="#web存储技术" aria-hidden="true">#</a> web存储技术</h3><p>HTML中，Web存储技术是用来在浏览器本地存储数据的一组API。Web存储技术包括localStorage、sessionStorage和IndexedDB。以下是详细介绍。</p><ol><li>localStorage</li></ol><p>localStorage是用来在浏览器本地永久存储数据的技术。它允许开发者将数据存储在键值对的形式下，以供随时获取。localStorage的优点是能够保存大量数据，并且在用户关闭浏览器后仍能保持存在。可以使用最简单的setItem()和getItem()方法来读取/写入数据：</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token comment">//写入数据</span>
localStorage<span class="token punctuation">.</span><span class="token function">setItem</span><span class="token punctuation">(</span><span class="token string">&quot;key&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;value&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">//读取数据</span>
<span class="token keyword">var</span> value <span class="token operator">=</span> localStorage<span class="token punctuation">.</span><span class="token function">getItem</span><span class="token punctuation">(</span><span class="token string">&quot;key&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>localStorage还具有removeItem()和clear()等方法来删除数据或清空存储区域。</p><ol start="2"><li>sessionStorage</li></ol><p>sessionStorage也是用于在本地存储数据的技术。与localStorage不同的是，它仅在当前会话期间有效，并在用户关闭浏览器后自动清除。与localStorage相同，sessionStorage使用键值对来存储数据，并且具有相似的API。例如：</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token comment">//写入数据</span>
sessionStorage<span class="token punctuation">.</span><span class="token function">setItem</span><span class="token punctuation">(</span><span class="token string">&quot;key&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;value&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">//读取数据</span>
<span class="token keyword">var</span> value <span class="token operator">=</span> sessionStorage<span class="token punctuation">.</span><span class="token function">getItem</span><span class="token punctuation">(</span><span class="token string">&quot;key&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><ol start="3"><li>IndexedDB</li></ol><p>IndexedDB是一种高级的本地数据库API，允许客户端应用程序存储结构化数据。它支持事务处理和索引访问等功能，并允许开发者在浏览器中存储大量数据。 IndexedDB使用基于对象式的存储模型，具体包括以下API：</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token comment">// 打开数据库，返回idb实例</span>
<span class="token keyword">var</span> request <span class="token operator">=</span> indexedDB<span class="token punctuation">.</span><span class="token function">open</span><span class="token punctuation">(</span><span class="token string">&quot;Database Name&quot;</span><span class="token punctuation">,</span> version<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">//数据存入</span>
<span class="token keyword">var</span> transaction <span class="token operator">=</span> db<span class="token punctuation">.</span><span class="token function">transaction</span><span class="token punctuation">(</span><span class="token punctuation">[</span>store_name<span class="token punctuation">]</span><span class="token punctuation">,</span><span class="token string">&#39;readwrite&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> objectStore <span class="token operator">=</span> transaction<span class="token punctuation">.</span><span class="token function">objectStore</span><span class="token punctuation">(</span>store_name<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> request <span class="token operator">=</span> objectStore<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> key<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">//数据读取</span>
<span class="token keyword">var</span> transaction <span class="token operator">=</span> db<span class="token punctuation">.</span><span class="token function">transaction</span><span class="token punctuation">(</span><span class="token punctuation">[</span>store_name<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> objectStore <span class="token operator">=</span> transaction<span class="token punctuation">.</span><span class="token function">objectStore</span><span class="token punctuation">(</span>store_name<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> request <span class="token operator">=</span> objectStore<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>总之，在HTML中可以使用Web存储技术来进行本地数据的存储和管理。具体使用应根据需求进行选择和调整，比如使用localStorage、sessionStorage或IndexedDB。需要注意的是，这些技术虽然方便，但也需要谨慎使用，避免出现隐私泄露、性能问题等风险。</p></div><!--[--><!--]--></div><footer class="page-meta"><!----><!----><!----></footer><nav class="page-nav"><p class="inner"><!----><span class="next"><a href="/preview/dev-edge/frontend/css/" class="" aria-label="CSS知识点"><!--[--><!--]--> CSS知识点 <!--[--><!--]--></a></span></p></nav><!--[--><!--]--></main><!--]--></div><!----><!--]--></div>
    <script type="module" src="/preview/dev-edge/assets/app-5517e208.js" defer></script>
  </body>
</html>
